package net.jblog.struts.tools;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Conversions {

	
	public static String dateToString(Date date) {
		if(date != null) {
			SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
			return sdf.format(date);
		}
		return null;
	}
	
	public static Date stringToDate(String date) {
		if(date != null) {
			Date d = null;
			try {
				SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
				ParsePosition pos = new ParsePosition(0);
				d = formatter.parse(date,pos);
			} catch (RuntimeException e) {
				e.printStackTrace();
			}
			return d;		
		}
		return null;
	}

}
